#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <fstream>

using namespace std;

const int INF = numeric_limits<int>::infinity();
const int MAX = numeric_limits<int>::max();

int nod(int a,int b) {
    if (a == INF || a == 0) return b;
    if (b == INF || b == 0) return a;
    if (a < 0) a = (-1) * a;
    if (b < 0) b = (-1) * b;
    while (a != 0 && b !=0) {
       if (a >= b) a = a % b;
       else b = b % a;
    }
 return a+b; // one of them is zero
 }

int rmq(vector<int>& segmentTree, int leftEnd, int rightEnd) {
    int answer = MAX;

    int n = segmentTree.size() / 2;
    leftEnd = leftEnd + n - 1;
    rightEnd = rightEnd + n - 1;

    while (leftEnd <= rightEnd) {
        if (leftEnd % 2 != 0) answer = nod(answer, segmentTree[leftEnd]);
        if (rightEnd % 2 == 0) answer = nod(answer, segmentTree[rightEnd]);
        leftEnd = (leftEnd + 1) / 2;
        rightEnd = (rightEnd - 1) / 2;
    }

    return answer;
}

int main() {
    vector<int> segmentTree;
    int dataAmount;
    cin >> dataAmount;
    segmentTree.push_back(0); //to start from the first element

    for (int i = 0; i < dataAmount; ++i) {
		int element;
        cin >> element;
        segmentTree.push_back(element);
    }

	int treeDepth = (1 << ((int)(log((double)(dataAmount - 1)) / log(2.0)) + 1));
	
    segmentTree.resize(2 * treeDepth, MAX);

    for (int i = treeDepth; i < 2 * treeDepth; ++i) {
        segmentTree[i] = segmentTree[i - treeDepth + 1];
    }

    segmentTree[2*treeDepth - 1] = segmentTree[treeDepth];

    for (int i = treeDepth - 1; i > 0; ++i) {
        segmentTree[i] = nod(segmentTree[2 * i], segmentTree[2 * i + 1]);
    }

	return 0;

    int requestsAmount;
    cin >> requestsAmount;

    for (int i=0; i < requestsAmount; ++i) {
		int leftEnd, rightEnd;
        cin >> leftEnd >> rightEnd;
        if (leftEnd > 0 && rightEnd <= dataAmount ) {
            cout << rmq(segmentTree, leftEnd, rightEnd) << endl;
        } else {
            cout << "Error: invalid index" << endl;
        }
    }

    system("pause");
    return 0;
}